<?php require_once '../library/Question.php'; ?>
<?php require_once '../library/Score.php'; ?>
<?php
$Question = new Question();
$Question->checkUser();
$questions = $Question->setLevel(1)->find('ORDER BY `number` ASC', false);
$Score = new Score();
$msg = '';
$topic = '';
$result = null;
if (isset($_POST['submit'])) {
    //echo '<pre>';
    //print_r($_POST);
    unset($_POST['submit']);
    $values = array_values($_POST);
    if (!empty($values)) {
        $result = $Score->prepareAndSaveScore($_POST);
    } else {
        $msg = "<b style='color: #f00;'>Please answer at least 1 question</b>";
    }
    //
    //Score::prepareAndSaveScore($_POST);
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>Home</title>
    <link rel="stylesheet" href="../css/StyleSheet/styles.css" type="text/css"/>
    <script type="text/javascript" src="../js/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="../lib/jquery-ui/jquery-ui-1.8.15.custom.min.js"></script>
    <script type="application/javascript" src="../js/logIn.js"></script>
    <style type="text/css">
        .msg {
            padding: 10px;
            text-align: center;

        }

        .t {
            border-collapse: collapse;
            width: 100%;
        }

        .t tr th {
            width: 40%;
            padding: 2px;
            text-align: center;
            text-transform: uppercase;
            background: #333;
            color: #e1e1e1;
        }

        .t tr td {
            padding: 2px 6px;
            margin: 2px
        }
    </style>
</head>

<body>
<div id="container">
    <div id="header">
        <h1><span>FIND YOUR MAJOR</span></h1>

        <div id="slogan-text" class="header-slogan">your major partner</div>

    </div>
    <div id="nav">
        <ul>
            <Li><a href="./">Home</a></li>
            <Li><a href="about.php">About Us</a></li>
            <li><a href="">Majors</a></li>
            <Li><a href="">Schools</a></li>
            <Li><a href="contact.php">Contact Us</a></li>
            <Li><a href="student_info.php" id="quiz" class="quiz">Take Quiz</a></li>

        </ul>

    </div>
    <div id="content">

        <div id="page" style="width: 99%;">
            <h2>Welcome</h2>

            <div class="msg"><?php echo $msg; ?></div>

            <?php if (is_resource($result)) { ?>
            <table class="t">
                <tr>
                    <th>Major</th>
                    <th>Major Category</th>
                    <th>Major Group</th>
                </tr>
            <?php while ($major = mysql_fetch_object($result)) { ?>
                <tr>
                    <td><?php echo $major->major; ?></td>
                    <?php $category = $Score->getMajorCategory($major->major_category_id); ?>
                    <td><?php if ($category ) { echo $category->category; } ?></td>
                    <?php $group = $Score->findMajorGroup($major->recomendation_group_id); ?>
                    <td><?php if ($group) { echo $group->group; } ?></td>
                </tr>
                <?php } ?>
            <?php } ?>
        </table>
        </div>
        <div class="clear"></div>
    </div>

    <div id="footer">
        <p>&copy; 2012 ernydey,All rights reserved.</p>
    </div>

</div>
<!--layer box ends-->
</body>
</html>
